source the R script, make.R to generate the project document.

> source("make.R")

This document was generated on 2015-12-10 20:31:26.

1 Project repository

Live version is stored here. Static version is this document.

This document is for the Cognitive Impairment topic.

For other topics, see links from the project repository.

2 Scripts

Sequence of scripts:

prologue.Rmd %>% runMetaAnalysis.Rmd %>% epilogue.Rmd

3 Prologue

  1. Set path of input data sources
  2. Load devtools
  3. Source the loadPkg function
  4. Load packages
  5. Source the makeMetadata function
  6. Start the job timer
## Sourcing https://gist.githubusercontent.com/benjamin-chan/3b59313e8347fffea425/raw/84a146f3cde6330b901521710d513fa9d0b96951/loadPkg.R
## SHA-1 hash of file is 7bdcd4569a86aa9fff8ced241327992c550a16ce
## Loading required package: data.table
## data.table 1.9.6  For help type ?data.table or https://github.com/Rdatatable/data.table/wiki
## The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
## Loading required package: openxlsx
## Loading required package: googlesheets
## Loading required package: haven
## Loading required package: xtable
## Loading required package: metafor
## Loading required package: Matrix
## Loading 'metafor' package (version 1.9-9). For an overview 
## and introduction to the package please type: help(metafor).
## Sourcing https://gist.githubusercontent.com/benjamin-chan/091209ab4eee1f171540/raw/5043f40fb0c15036b0ce53079045d7d1beae5609/makeMetadata.R
## SHA-1 hash of file is 66a9fa7f31fa5e4e4448ed18f18db768a1c5a70f

4 Meta-analysis

Cognitive impairment is modeled with a multilevel mixed effects model. Fixed effect for cognitive domain is modeled, one effect size for each of the 8 domains. The random effects model assumes each data point is a random observation from a large population of studies. The single-level random effects model additionally assumes each data point is independent. The multilevel random effects model relaxes the independence assumption, allowing for data points to be correlated. In our study, we have multiple measurements within cognitive domain. So, data points are correlated within study.

Models were estimated using the rma.mv() function from the metafor package for R. Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1-48.

Load tidy data.

f <- sprintf("%s/%s", pathOut, "AllStudies.RData")
load(f, verbose=TRUE)
## Loading objects:
##   D
##   metadata
metadata$timeStamp
## [1] "2015-12-10 07:48:28 PST"
metadata$colNames
##  [1] "author"             "cognitiveDomain"    "cognitiveTest"     
##  [4] "isHigherWorse"      "scoreType"          "monthsPostTxPre"   
##  [7] "treatmentGroupPre"  "nPre"               "meanPre"           
## [10] "sdPre"              "monthsPostTxPost"   "treatmentGroupPost"
## [13] "nPost"              "meanPost"           "sdPost"            
## [16] "yi"                 "vi"

Remove studies with missing data.

unique(D[is.na(yi), .(author, cognitiveDomain, cognitiveTest, yi)])
##    author            cognitiveDomain cognitiveTest yi
## 1:    Fan Attn/Wkg Mem/Concentration      Trails A NA
## 2:    Fan                   Exec Fxn      Trails B NA
D <- D[!is.na(yi)]

Label each data point. Will need this for the multilevel random effects model specification.

D <- D[, j := factor(sequence(D[, .N, .(author, cognitiveDomain)][, N]))]
D <- D[, k := factor(1:nrow(D))]

4.1 Pooled domain effects

M <- rma.mv(yi ~ cognitiveDomain - 1,
            vi,
            random = list(~ cognitiveTest | author,
                          ~ 1 | author),
            struct="CS",
            data=D,
            slab=sprintf("%s: %s (%s)", author, cognitiveDomain, cognitiveTest))
summary <- data.frame(M[c("b", "se", "zval", "pval", "ci.lb", "ci.ub")])
rownames(summary) <- gsub("cognitiveDomain", "", rownames(summary))
print(xtable(summary, digits=c(0, rep(3, 3), 4, rep(3, 2))), type="html")
b se zval pval ci.lb ci.ub
Attn/Wkg Mem/Concentration 0.018 0.071 0.253 0.8006 -0.122 0.158
Exec Fxn 0.095 0.114 0.838 0.4023 -0.127 0.318
Information Proc Speed 0.101 0.132 0.761 0.4467 -0.159 0.360
Motor Speed -0.069 0.139 -0.500 0.6168 -0.341 0.203
Verbal Ability/Language 0.275 0.134 2.046 0.0408 0.012 0.538
Verbal Memory 0.515 0.108 4.751 0.0000 0.303 0.727
Visual Memory 0.646 0.140 4.634 0.0000 0.373 0.920
Visuospatial 0.299 0.216 1.382 0.1670 -0.125 0.723
summary(M)
## 
## Multivariate Meta-Analysis Model (k = 117; method: REML)
## 
##   logLik  Deviance       AIC       BIC      AICc  
## -97.2434  194.4868  216.4868  246.0917  219.2085  
## 
## Variance Components: 
## 
##             estim    sqrt  nlvls  fixed  factor
## sigma^2    0.0446  0.2113      8     no  author
## 
## outer factor: author        (nlvls = 8)
## inner factor: cognitiveTest (nlvls = 110)
## 
##              estim    sqrt  fixed
## tau^2       0.0791  0.2812     no
## rho        -0.5361             no
## 
## Test for Residual Heterogeneity: 
## QE(df = 109) = 397.1480, p-val < .0001
## 
## Test of Moderators (coefficient(s) 1,2,3,4,5,6,7,8): 
## QM(df = 8) = 48.5833, p-val < .0001
## 
## Model Results:
## 
##                                            estimate      se     zval
## cognitiveDomainAttn/Wkg Mem/Concentration    0.0180  0.0714   0.2526
## cognitiveDomainExec Fxn                      0.0951  0.1135   0.8375
## cognitiveDomainInformation Proc Speed        0.1006  0.1322   0.7609
## cognitiveDomainMotor Speed                  -0.0694  0.1388  -0.5004
## cognitiveDomainVerbal Ability/Language       0.2750  0.1344   2.0458
## cognitiveDomainVerbal Memory                 0.5150  0.1084   4.7512
## cognitiveDomainVisual Memory                 0.6464  0.1395   4.6335
## cognitiveDomainVisuospatial                  0.2992  0.2165   1.3819
##                                              pval    ci.lb   ci.ub     
## cognitiveDomainAttn/Wkg Mem/Concentration  0.8006  -0.1218  0.1579     
## cognitiveDomainExec Fxn                    0.4023  -0.1274  0.3176     
## cognitiveDomainInformation Proc Speed      0.4467  -0.1585  0.3597     
## cognitiveDomainMotor Speed                 0.6168  -0.3414  0.2025     
## cognitiveDomainVerbal Ability/Language     0.0408   0.0115  0.5385    *
## cognitiveDomainVerbal Memory               <.0001   0.3026  0.7275  ***
## cognitiveDomainVisual Memory               <.0001   0.3730  0.9198  ***
## cognitiveDomainVisuospatial                0.1670  -0.1252  0.7235     
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Save working data tables to file.

metadata <- makeMetadata(D)
f <- sprintf("%s/%s", pathOut, "metaAnalysisCognitiveImpairment.RData")
save(D, metadata, M, summary, file=f)
message(sprintf("%s saved on: %s\nFile size: %s KB", 
                f,
                file.mtime(f),
                file.size(f) / 1e3))
## Output/metaAnalysisCognitiveImpairment.RData saved on: 2015-12-10 20:31:32
## File size: 51.024 KB
f <- sprintf("%s/%s", pathOut, "metaAnalysisCognitiveImpairment-Data.csv")
write.csv(D, file=f, row.names=FALSE)
f <- sprintf("%s/%s", pathOut, "metaAnalysisCognitiveImpairment-summary.csv")
write.csv(summary, file=f, row.names=FALSE)

4.2 Plot of effect sizes

The xlim settings require fine-tuning.

## png 
##   2

Full resolution file is here.

4.3 Plot to assess publication bias

See BMJ 2011;342:d4002 for a guide to interpret funnel plots.

5 Epilogue

## Sourcing https://gist.githubusercontent.com/benjamin-chan/80149dd4cdb16b2760ec/raw/a1fafde5c5086024dd01d410cc2f72fb82e93f26/sessionInfo.R
## SHA-1 hash of file is 41209357693515acefb05d4b209340e744a1cbe4
## $timeStart
## [1] "2015-12-10 20:31:31"
## 
## $timeEnd
## [1] "2015-12-10 20:31:34 PST"
## 
## $timeElapsed
## [1] "3.155468 secs"
## 
## $Sys.info
##        sysname        release        version       nodename        machine 
##      "Windows"        "7 x64"   "build 9200"     "FAMILYPC"       "x86-64" 
##          login           user effective_user 
##          "Ben"          "Ben"          "Ben" 
## 
## $sessionInfo
## R version 3.2.2 (2015-08-14)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 8 x64 (build 9200)
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] metafor_1.9-9      Matrix_1.2-2       xtable_1.7-4      
##  [4] haven_0.2.0        googlesheets_0.1.0 openxlsx_3.0.0    
##  [7] data.table_1.9.6   extrafont_0.17     DiagrammeR_0.8    
## [10] devtools_1.7.0    
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.11.6       cellranger_1.0.0  formatR_1.2      
##  [4] bitops_1.0-6      tools_3.2.2       digest_0.6.8     
##  [7] jsonlite_0.9.16   evaluate_0.8      lattice_0.20-33  
## [10] DBI_0.3.1         rstudioapi_0.3.1  yaml_2.1.13      
## [13] parallel_3.2.2    Rttf2pt1_1.3.3    httr_0.6.1       
## [16] stringr_1.0.0     dplyr_0.4.3       knitr_1.11       
## [19] htmlwidgets_0.3.2 grid_3.2.2        R6_2.0.1         
## [22] rmarkdown_0.8     RJSONIO_1.3-0     extrafontdb_1.0  
## [25] magrittr_1.5      htmltools_0.2.6   assertthat_0.1   
## [28] stringi_0.4-1     RCurl_1.95-4.6    chron_2.3-47